function isPassive() {
    var supportsPassiveOption = false;
    try {
        addEventListener("test", null, Object.defineProperty({}, 'passive', {
            get: function () {
                supportsPassiveOption = true;
            }
        }));
    } catch(e) {}
    return supportsPassiveOption;
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, isPassive() ? {
    capture: false,
    passive: false
} : false);

function IScrollUtils(scroller,options){
    this.options = {
        scroller:scroller,
        isPullDown:false,
        isPullUp:false,
        pullDownId:"#pullDown",
        pullUpId:"#pullUp",
        wrapperId:"#wrapper",
        pullMode:"both",
        timeDelayMs:500,
        pullDistance:70,
        scrollPullDownEventCallBack:function(){
            console.log("execute scrollEndEvent...");
        },
        scrollPullUpEventCallBack:function(){
            console.log("execute scrollEndEvent...");
        }
    }
    this.options = Object.assign(this.options, options);//将设定参数和默认参数进行合并操作;
    IScrollUtils.prototype.scrollPullUpEventCallBack=this.options.scrollPullUpEventCallBack;
    IScrollUtils.prototype.scrollPullDownEventCallBack=this.options.scrollPullDownEventCallBack;
    IScrollUtils.prototype.scrollEventInit=function(){
        var self =this;
        /**
         * 下拉事件处理
         */
        this.options.scroller.on("scroll",function(){
            var maxScroll =  this.maxScrollY
            var num = -1*(self.options.pullDistance);
            if(this.y>self.options.pullDistance && (self.options.pullMode==="pullDown" || self.options.pullMode==="both")){
                if(self.options.isPullDown){
                    return;
                }
                self.options.isPullDown=true;
                $(self.options.pullDownId).attr("style","display:block");
            }else if(this.y-maxScroll<num && (self.options.pullMode==="pullUp"|| self.options.pullMode==="both")){
                if(self.options.isPullUp){
                    return;
                }
                self.options.isPullUp=true;
                $(self.options.pullUpId).attr("style","display:block");
            }
        });

        /**
         * 下拉结束事件处理
         */
        this.options.scroller.on("scrollEnd",function(){
            if(self.options.isPullDown){
                setTimeout(function () {
                    self.scrollPullDownEventCallBack();
                    self.options.scroller.refresh();
                    self.options.isPullDown = false;
                    $(self.options.pullDownId).attr("style", "display:none");
                },self.options.timeDelayMs)
            }else if(self.options.isPullUp){
                setTimeout(function () {
                    self.scrollPullUpEventCallBack();
                    self.options.scroller.refresh();
                    self.options.isPullUp = false;
                    $(self.options.pullUpId).attr("style", "display:none");
                },self.options.timeDelayMs)
            }
        });
    }
}